.contextual
  = icon_link_to :balance_sheet, :action => :balance_sheet, :by_date => params[:by_date], :years => params[:years]
  = icon_link_to :print, :format => :pdf, :by_date => params[:by_date], :years => params[:years]
  = contextual_links_for

%h2= t('bookyt.profit_report', :dates => @dates.map{|date| date.first.to_s + '-' + date.last.to_s}.join(", "), :company => [@tenant.to_s, @tenant.company.vcard.extended_address].map(&:presence).compact.join(" - ") )

%table.table.table-striped.collection{:width => "100%"}
  %thead
    %tr
      %th{:colspan => "2"}
      -for @date in @dates
        %th.right
          %h2= @date.last.year

  %tbody
    = render 'account_group_sheet', :group => 'costs'
    = render 'account_group_sheet', :group => 'earnings'

  %tfoot
    %tr
      %th{:colspan => "2"}
        %h3= t('bookyt.difference')

      - for @date in @dates
        %th.right
          %h3= currency_fmt(Account.by_type('earnings').saldo(@date) - Account.by_type('costs').saldo(@date))

= render 'filters/by_fiscal_year'
